A Counter That Counts Input Pulses Or Events Count Maybe Up, Down Or Both . It's Depends On Type Of Counter. Counter Track An Events Of How Many Times Has Occurred. For Example Counter Used To Count How Many Products Produced Or Delivered. Counter Count When Input Pulse Change From True To False Or False To True. Than Compare The Result With Preset Value And Current Value. If Both Are Equal To Each Other Than Counter Process Is Completed. In Omron Plc Counter Are Generally Two Type Binary And Bcd Counter And Than Sub Classified As Following
omron have following timer
following image shows all counter block.
CNT is BCD type decrementing counter. this counter decrement by 1 of Set value every time that the count input goes from OFF to ON. when the counter PV value is set to zero than counter operation completed and counter done bit is set to true. PV = SV - 1 every count input change from false to true. range of counter set value 0000 to 9999.
above example shows simple example of omron CNT counter. in this example C0005 is counter number and #100 is SV value, P_1s is set every 1 second pulse bit. I:0.03 reset bit of counter. when counter input I:0.02 is set to true counter decrement SV by 1 until it reaches 0. when PV reaches to zero than counter operation stop and counter bit set to 1. Reset bit reset counter.
CNTX is binary type decrementing counter. this counter is also decrement counter and operation is same as BCD decrementing counter. SV value range from &0 to &65535 (decimal) or #0000 to #FFFF (hex).
Note:- reset bit of counter: if reset bit is true so timer PV value never decrement. Always make reset bit false when not required.
CNTR is use as increment and decrement counter. Counter increment by 1 every timer when increment input goes from false to true and decrement by 1 every time when decremented input change from OFF to ON. if both increment and decrement input is set to true than PV value not change, so it work only one case either increment or decrement. reset bit reset counter.
operation is same as BCD REVERSIBLE COUNTER only deference of set value range range is start from &0 to &65535 (decimal) or #0000 to #FFFF (hex).
for reset timer and counter have special instructions as following
Resets the timers or counters within the specified range of timer or counter numbers. structure of CNR and CNR/CNRX
above is sample code for CNR and CNRX in first rung when input is changed from false to true than CNR instructions reset all the counter range from C0 to C10 and set PV value to 9999 for BCD and FFFF for binary, counter's done bit set to false. second rung reset all the timer from T0000 to T0010 and set timer done bit to false.
shows a basic example where counter set value set by move instruction. counter PV value move to D0 for another use.